Aqua skill-sharing sessions
2025-02-03
spatial-autocorrelation-in-statistical-models-friend-or-foe
Kühn & Dormann (2012). Journal of Biogeography https://doi.org/10.1111/j.1365-2699.2012.02707.x
s()Matérn is named after Bertil Matérn, a statistican born in Gothenburg and active at Skogsstyrelsen, which became part of SLU in 1977!
Miller, Glennie, & Seaton (2020). Journal of Agricultural, Biological and Environmental Statistics
fmesher::fm mesh 2d()Lindgren, Rue, & Lindström (2011). Journal of the Royal Statistical Society: Series B (Statistical Methodology)
Miller, Glennie, & Seaton (2020). Journal of Agricultural, Biological and Environmental Statistics
fit1 <- sdmTMB(no_km2 ~ year_f + survey,
data = catch,
family = delta_gamma(type = "poisson-link"),
spatiotemporal = "off",
spatial = "off",
time = "year")
s <- sanity(fit1)
s$hessian_ok
[1] TRUE
$eigen_values_ok
[1] TRUE
$nlminb_ok
[1] TRUE
$range_ok
[1] TRUE
$gradients_ok
[1] TRUE
$se_magnitude_ok
[1] TRUE
$se_na_ok
[1] TRUE
$sigmas_ok
[1] TRUE
$all_ok
[1] TRUE
# A tibble: 14 × 5
term estimate std.error conf.low conf.high
<chr> <dbl> <dbl> <dbl> <dbl>
1 (Intercept) 0.561 0.834 -1.07 2.19
2 year_f2013 -1.53 0.838 -3.18 0.111
3 year_f2014 -2.33 1.00 -4.29 -0.374
4 year_f2015 -0.672 0.735 -2.11 0.769
5 year_f2016 -0.696 0.735 -2.14 0.745
6 year_f2017 -0.805 0.740 -2.26 0.646
7 year_f2018 -0.212 0.752 -1.69 1.26
8 year_f2019 -0.355 0.740 -1.81 1.10
9 year_f2020 -1.06 0.751 -2.53 0.417
10 year_f2021 -0.665 0.757 -2.15 0.820
11 year_f2022 -0.775 0.769 -2.28 0.732
12 year_f2023 -0.443 0.763 -1.94 1.05
13 year_f2024 -1.00 0.767 -2.51 0.500
14 surveyIBTS 0.832 0.272 0.299 1.37
# A tibble: 3 × 5
term estimate std.error conf.low conf.high
<chr> <dbl> <dbl> <dbl> <dbl>
1 range 24.6 14.7 7.62 79.3
2 sigma_E 1.74 0.885 0.643 4.72
3 rho 0.986 NA 0.938 0.997
# A tibble: 4 × 5
term estimate std.error conf.low conf.high
<chr> <dbl> <dbl> <dbl> <dbl>
1 range 4.65 4.97 0.571 37.8
2 phi 4.12 0.615 3.08 5.52
3 sigma_E 0.791 0.591 0.183 3.42
4 rho 0.754 NA -0.173 0.973
# Calculate indices
inds <- list()
for (i in unique(d$prey_group)) {
pred_grid$prey_group <- as.factor(i)
p <- predict(m2, newdata = pred_grid, return_tmb_object = TRUE)
t <- get_index(p, area = 1 / nrow(pred_grid |> filter(year == 2000)))
inds[[i]] <- t |>
mutate(
prey_group = i
)
}
ind <- bind_rows(inds)